package me.leon.ext.android

import android.app.*
import android.app.job.JobScheduler
import android.content.ClipboardManager
import android.content.Context
import android.hardware.SensorManager
import android.location.LocationManager
import android.media.AudioManager
import android.media.MediaRouter
import android.net.ConnectivityManager
import android.net.wifi.WifiManager
import android.os.BatteryManager
import android.os.PowerManager
import android.os.Vibrator
import android.os.storage.StorageManager
import android.telephony.CarrierConfigManager
import android.telephony.SubscriptionManager
import android.telephony.TelephonyManager
import android.view.LayoutInflater
import android.view.WindowManager
import android.view.accessibility.AccessibilityManager
import android.view.inputmethod.InputMethodManager
import androidx.core.content.ContextCompat

/** Return system service which type is [T] */
inline fun <reified T> Context.getSystemService(): T? =
    ContextCompat.getSystemService(this, T::class.java)

val Context.windowManager
    get() = getSystemService<WindowManager>()
val Context.clipboardManager
    get() = getSystemService<ClipboardManager>()
val Context.layoutInflater
    get() = getSystemService<LayoutInflater>()
val Context.activityManager
    get() = getSystemService<ActivityManager>()
val Context.powerManager
    get() = getSystemService<PowerManager>()
val Context.alarmManager
    get() = getSystemService<AlarmManager>()
val Context.notificationManager
    get() = getSystemService<NotificationManager>()
val Context.keyguardManager
    get() = getSystemService<KeyguardManager>()
val Context.locationManager
    get() = getSystemService<LocationManager>()
val Context.searchManager
    get() = getSystemService<SearchManager>()
val Context.storageManager
    get() = getSystemService<StorageManager>()
val Context.vibrator
    get() = getSystemService<Vibrator>()
val Context.connectivityManager
    get() = getSystemService<ConnectivityManager>()
val Context.wifiManager
    get() = getSystemService<WifiManager>()
val Context.audioManager
    get() = getSystemService<AudioManager>()
val Context.mediaRouter
    get() = getSystemService<MediaRouter>()
val Context.telephonyManager
    get() = getSystemService<TelephonyManager>()
val Context.sensorManager
    get() = getSystemService<SensorManager>()
val Context.subscriptionManager
    get() = getSystemService<SubscriptionManager>()
val Context.carrierConfigManager
    get() = getSystemService<CarrierConfigManager>()
val Context.inputMethodManager
    get() = getSystemService<InputMethodManager>()
val Context.uiModeManager
    get() = getSystemService<UiModeManager>()
val Context.downloadManager
    get() = getSystemService<DownloadManager>()
val Context.batteryManager
    get() = getSystemService<BatteryManager>()
val Context.jobScheduler
    get() = getSystemService<JobScheduler>()
val Context.accessibilityManager
    get() = getSystemService<AccessibilityManager>()
